package com.designPattern.FactoryMode;

import java.util.Scanner;

/**
 * Created by Administrator on 2018/1/2.
 */

public class TestFactory {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("请输入第一个数：");
            String num1 = scanner.nextLine();
            System.out.println("请输入第二个数：");
            String num2 = scanner.nextLine();
            System.out.println("请输入运算符：");
            String oper = scanner.nextLine();
            Operation operation = OperationFactory.createOperation(oper);
            if (operation != null) {
                operation.setNum1(Double.parseDouble(num1));
                operation.setNum2(Double.parseDouble(num2));
                System.out.println("结果：" + operation.operation());
            }
        }
    }
}
